//app.js

App({
  onLaunch: function () {
    //云开发初始化
    wx.cloud.init({
      env: 'cloud1-3g8nprxnc79fbfe0',
      traceUser: true

    })
this.getOpenid(); //获取openid以确定用户
    //调用API从本地缓存中获取数据
    var logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

  },
  //app.js

  //获取授权的头像信息  检测授权
  getOpenid() {
    return new Promise((resolve, reject) => {
      // 获取用户信息
      wx.cloud.callFunction({
        name: 'getOpenid',
        complete: res => {
          this.globalData.userId=res.result.openid;
          console.log("app: "+this.globalData.userId);
          resolve(this.globalData.userId);
        }
      })
    })
  },


  globalData: {
    userId:null,
    userInfo: null,
    userHas: false
  },
 

})
